package com.jzh.thread;

import static java.lang.Thread.currentThread;

class MyThread01 extends Thread{
    @Override
    public void run() {
        System.out.println("这是一个子线程");
    }
}

class MyThread02 implements Runnable{
    @Override
    public void run() {
//        int count = 0;
//        while (count<100){
//            System.out.println(count);
//
//            try {
//                Thread.sleep(1000);
//                count++;
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//
//
//        }
        System.out.println("这是一个子线程");
        currentThread().setPriority(6);
    }
}



public class Thread01 {
    public static void main(String[] args) {

        //2.
        MyThread02 mythread02 = new MyThread02();
        Thread thread = new Thread(mythread02);
        thread.start();
        System.out.println("子线程" +thread.getPriority());
        System.out.println("主线程"+currentThread().getPriority());
        System.out.println("这是主线程");
        currentThread().setPriority(8);
        System.out.println("子线程" +thread.getPriority());
        System.out.println("主线程"+currentThread().getPriority());











        //1.
//        Thread myThread = new MyThread01();
//        myThread.start();
//        try {
//            Thread.sleep(2000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//
//        System.out.println("这是主线程");

    }

}
